<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>企业员工管理-系统日志</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="static/css/font.css">
    <link rel="stylesheet" href="static/css/xadmin.css">
    <script type="text/javascript" src="static/js/jquery-3.3.1.js"></script>
    <script type="text/javascript" src="static/lib/layui/layui.js"></script>
    <script type="text/javascript" src="static/js/xadmin.js"></script>


</head>

<body class="layui-anim layui-anim-up">

<div class="x-nav">
      <span class="layui-breadcrumb">
        <a>首页</a>
        <a>系统日志</a>
        <a>
          <cite>日志列表</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body" id="container">
    <div class="layui-row">
        <div class="demoTable  layui-col-md11 layui-form">
            <div class="layui-inline">
                <input class="layui-input" name="name" id="search-name" autocomplete="off" placeholder="输入要查找的用户工号">
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">起始日期</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="startTime" placeholder="">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">截止日期</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="endTime" placeholder="">
                </div>
            </div>
            <button class="layui-btn" data-type="reload">搜索</button>
        </div>
    </div>


    <div style="text-align: center">
        <table class="layui-table"
               lay-data="{height: 'full-160', cellMinWidth:80, url:'log/pageLogInfo', request:{ pageName: 'pageCount', limitName: 'pageSize' }, page:true, id:'idTest'}"
               lay-filter="demo">
            <thead>
            <tr>
                <th lay-data="{field:'logAccount', width:300, fixed: true,align: 'center'}">操作账号</th>
                <th lay-data="{field:'createTime', minWidth:80,align: 'center'}">操作时间</th>
                <th lay-data="{field:'logMethod', minWidth:80,align: 'center'}">执行函数</th>
                <th lay-data="{field:'logValue', minWidth:300,align: 'center'}">操作描述</th>
                <!--                <th lay-data="{fixed: 'right', width:295, align:'center', toolbar: '#barDemo'}"></th>-->
            </tr>
            </thead>
        </table>
    </div>

</div>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script>
    layui.use('table', function () {
        // layui.use(['form', 'table','layedit', 'laydate'], function(){
        var table = layui.table;


        //监听工具条
        table.on('tool(demo)', function (obj) {
            var data = obj.data;
            if (obj.event === 'detail') {
                layer.msg('ID：' + data.id + ' 的查看操作');
            } else if (obj.event === 'del') {
                layer.confirm('确定要删除吗', function (index) {
                    $.ajax({
                        type: 'post',
                        url: 'department/deleteByPrimaryKey.do',
                        data: {"id": data.dId},
                        dataType: 'json',
                        success: function (result) {
                            if (result.code == 100) {
                                layer.msg('部门删除成功!', {icon: 1, time: 4000});
                                obj.del();
                            } else {
                                layer.msg(result.message, {icon: 5, time: 1000});
                            }
                        },
                        error: function (data) {
                            layer.alert("抱歉！出现未知错误！", {icon: 5});
                        }

                    });
                    obj.del();
                    layer.close(index);
                    // location.reload();
                });
            } else if (obj.event === 'edit') {
                // layer.alert('编辑行：<br>'+ JSON.stringify(data));
                x_admin_show('编辑', 'toPage.do?url=admin/department/department-edit.html?dId=' + data.dId
                    + '&dName=' + data.dName + '&dLevel=' + data.dLevel + '&dGsid=' + data.dGsid
                    + '&dRemark=' + data.dRemark, 650, 450);

            }
        });

        var $ = layui.$, active = {
            reload: function () {
                let searchID = $('#search-name').val();
                let startTime = $("#startTime").val();
                let endTime = $("#endTime").val();
                table.reload('idTest', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: {
                        account: searchID,
                        preDateTime: startTime,
                        aftDateTime: endTime
                    }
                });
            }
        };

        $('.demoTable .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });


    });
    layui.use('laydate', function () {
        let layDate = layui.laydate;

        // 渲染日期选择器
        //常规用法
        layDate.render({
            elem: '#startTime',
            type: 'datetime'
        });

        layDate.render({
            elem: '#endTime',
            type: 'datetime'
        });
    })
</script>

</body>

</html>